/**
 * Created by ranchenguang on 2017/09/14.
 * 每个页面对应一个 module 每个子页面对应一个 store js 文件
 */
import * as types from '../../mutation-types';

const state = {
  isLogin:false,
  info:{

  }
};

const getters = {
  //基础数据
  User_isLogin : state => state.isLogin,
};

//每个action包含一个promise请求，方便回调
const actions = {
  'HO/getList'( { commit }, params ){
    commit( types.HO_SB_LOADING, true );
    return Util.createPromise( 'list',params ).then( ( data ) => {
      commit( types.HO_SB_LOADING, false );
      commit( types.HO_SB_PAGINATION, data.page );
      commit( types.HO_SD_LIST, data.list );
      return data.list;
    } ).catch( ( data ) => {
      commit( types.HO_SB_LOADING, false );
      return data;
    } );
  },
};

const mutations = {
  [types.USER_IS_LOGIN] ( state, data ) {
    state.isLogin = data;
  }
};

export default {
  state,
  getters,
  actions,
  mutations
};